{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "recent-theme",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There was no error!\n",
      "输出成功，请打开 test.xlsx 查看输出结果\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "# 1. 建交互控制台\n",
    "from yolib.convertter import pattern_copier\n",
    "copier = pattern_copier()\n",
    "# 2. 请求读取数据\n",
    "copier.read_data(data_file=r'.\\data\\庆合废钢20210730.xlsx', idx=2, factory_name='大冶华鑫', receipt='入仓单')\n",
    "\n",
    "# 11. 请求读取模板\n",
    "copier.read_pattern(r'.\\data\\华鑫过磅单模板.xlsx',0)\n",
    "\n",
    "# copier.tidy_data = copier.tidy_data[(copier.tidy_data.日期=='2021-7-23')]\n",
    "\n",
    "copier.tidy_data['货主名称'] = '庆合'\n",
    "copier.tidy_data['序号'] = '01'\n",
    "copier.oto_loc = {\n",
    "            \"B2\": '序号',\n",
    "            \"B3\": '日期',\n",
    "            \"B4\": '货主名称',\n",
    "            \"B5\": '车牌号',\n",
    "            \"B6\": '货物名称',\n",
    "            \"B7\": '毛重',\n",
    "            \"B8\": '皮重',\n",
    "            \"B9\": '净重',\n",
    "            \"C10\": '扣重',\n",
    "            'C11': '扣款',\n",
    "            'B12': '备注',\n",
    "        }\n",
    "copier._mtm_loc = None\n",
    "\n",
    "copier.receipt='请款单'\n",
    "\n",
    "# adata = copier.tidy_data[copier.oto_loc.values()].drop_duplicates()\n",
    "\n",
    "# 15. 请求写入sheet\n",
    "copier.write_in_sheet(gap_between_blocks_in_a_page=0,number_of_blocks_per_page=1)\n",
    "\n",
    "# 19. sheet 页面设置\n",
    "copier.page_setup(margins=copier.NARROWER,paperSize='0',scale=100,)\n",
    "\n",
    "# 21. 输出结果\n",
    "copier.output('test.xlsx')\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "studied-height",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Ha',\n",
       " 'let',\n",
       " 'me',\n",
       " 'see',\n",
       " 'her',\n",
       " 'out',\n",
       " 'alas',\n",
       " 'he',\n",
       " 's',\n",
       " 'cold',\n",
       " 'Her',\n",
       " 'blood',\n",
       " 'is',\n",
       " 'settled',\n",
       " 'and',\n",
       " 'her',\n",
       " 'joints',\n",
       " 'are',\n",
       " 'stiff',\n",
       " 'Life',\n",
       " 'and',\n",
       " 'these',\n",
       " 'lips',\n",
       " 'have',\n",
       " 'long',\n",
       " 'been',\n",
       " 'separated',\n",
       " 'Death',\n",
       " 'lies',\n",
       " 'on',\n",
       " 'her',\n",
       " 'like',\n",
       " 'an',\n",
       " 'untimely',\n",
       " 'frost',\n",
       " 'Upon',\n",
       " 'the',\n",
       " 'sweetest',\n",
       " 'flower',\n",
       " 'of',\n",
       " 'all',\n",
       " 'the',\n",
       " 'field']"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import re\n",
    "# Shakespeare\n",
    "text = '''\n",
    "Ha! let me see her: out, alas! he's cold:\n",
    "Her blood is settled, and her joints are stiff;\n",
    "Life and these lips have long been separated:\n",
    "Death lies on her like an untimely frost\n",
    "Upon the sweetest flower of all the field.\n",
    "'''\n",
    "re.findall(r'\\b(\\w+)\\b',text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "urban-classic",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
